<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<%
usergeo_user=saferequest("usergeo_user",0)
usergeo_lat=saferequest("usergeo_lat",1)
usergeo_lng=saferequest("usergeo_lng",1)
usergeo_timestamp=saferequest("usergeo_timestamp",1)
usergeo_inmeters=saferequest("usergeo_inmeters",1)
usergeo_reverse=saferequest("usergeo_reverse",0)

set rs = Server.CreateObject("ADODB.Recordset")
sql="select top 1 * from usergeo where usergeo_user='"&usergeo_user&"' order by usergeo_id desc"
rs.open sql,conn,1,1
'response.write(sql)
'do while not rs.eof
	
'	rs.movenext
'loop
if not rs.eof then
	if cdbl(usergeo_timestamp)<>cdbl(rs("usergeo_timestamp")) then
		set cmd=server.CreateObject ("adodb.command")
		set cmd.ActiveConnection =conn
		sql="insert into usergeo(usergeo_user,usergeo_lat,usergeo_lng,usergeo_timestamp,usergeo_inmeters,usergeo_reverse) values('"&usergeo_user&"',"&usergeo_lat&","&usergeo_lng&","&usergeo_timestamp&","&usergeo_inmeters&",'"&usergeo_reverse&"')"
		cmd.CommandText =sql
		cmd.Execute
		
		'response.write(usergeo_timestamp&" "&rs("usergeo_timestamp"))
	end if
else
		set cmd=server.CreateObject ("adodb.command")
		set cmd.ActiveConnection =conn
		sql="insert into usergeo(usergeo_user,usergeo_lat,usergeo_lng,usergeo_timestamp,usergeo_inmeters,usergeo_reverse) values('"&usergeo_user&"',"&usergeo_lat&","&usergeo_lng&","&usergeo_timestamp&","&usergeo_inmeters&",'"&usergeo_reverse&"')"
		cmd.CommandText =sql
		cmd.Execute

	
end if
		set cmd=server.CreateObject ("adodb.command")
		set cmd.ActiveConnection =conn
		sql="update cl set cl_lat="&usergeo_lat&",cl_lng="&usergeo_lng&",cl_timestamp="&usergeo_timestamp&",cl_reverse='"&usergeo_reverse&"',cl_update='"&now()&"' where cl_usergeo='"&usergeo_user&"'"
		cmd.CommandText =sql
		cmd.Execute


	
rs.close
set rs=nothing
conn.close
set conn=nothing

%>

